package com.openarena.model.dao;

import com.openarena.model.Game;
import com.openarena.model.GameStat;
import java.util.Collections;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.hibernate.classic.Session;
import org.hibernate.criterion.Restrictions;

public class GameStatDAO extends InfArenaDAO {

    private static final Logger logger = Logger.getLogger(GameStatDAO.class.getCanonicalName());

    public GameStatDAO() {
       super();
    }

    public List<GameStat> getStatsForGame(Game game) {
        Session session = null;
        try {
            session = getSession();
            return session.createCriteria(GameStat.class).add(Restrictions.eq("gameId", game.getId())).list();
        } catch (Exception e) {
            logger.log(Level.SEVERE, "", e);
            return Collections.EMPTY_LIST;
        } finally {
            close(session);
        }
    }
}
